// autofire module, added by regret
#ifndef AUTOFIRE_H
#define AUTOFIRE_H

#ifndef NO_AUTOFIRE

#define MAX_PLAYER 4
#define MAX_AUTOFIRE_BUTTONS 6

// auto fire
class Autofire : public IAutofire {
public:
	enum { P_1 = 0, P_2, P_3, P_4, };
	enum { F_1 = 0, F_2, F_3, F_4, F_5, F_6, };

	bool enabled;
	unsigned defaultDelay;	// default delay (1 ~ 99)
	unsigned delay;			// delay (1 ~ 99)

	virtual void init();
	virtual void run();

	int set(int player, int fire, bool state);
	bool get(int player, int fire);

	Autofire();
	virtual ~Autofire();

private:
	struct AutofireButton {
		unsigned char* value;
		int inpIndex;
	};

	AutofireButton autofires[MAX_PLAYER][MAX_AUTOFIRE_BUTTONS]; // [player][button]
	bool autofireOn[MAX_PLAYER][MAX_AUTOFIRE_BUTTONS];
//	int autofireSize;	// number of buttons per player
	int delayCounter;
	bool method2;		// another autofire clear timer

	inline bool checkState(int player, int fire);
	inline void clear();
	inline void reset();
};

extern Autofire autofire;

#endif

#endif
